<script setup>
import { ref } from 'vue'
import PieChart from '@/components/Charts/PieChart.vue'
import ServerTable from '@/components/Tables/ServerTable.vue'
import { mockServerData } from '@/utils/mockData'

// 生成10条服务器数据
const serverData = ref(mockServerData(10))

// 资源指标数据
const metrics = ref([
  { title: 'CPU使用率', value: 75 },
  { title: '内存使用率', value: 60 },
  { title: 'GPU使用率', value: 45 },
  { title: '任务运行率', value: 30 }
])
</script>

<template>
  <div class="overview-container">
    <!-- 指标图表区 -->
    <div class="metrics-grid">
      <PieChart 
        v-for="metric in metrics"
        :key="metric.title"
        :title="metric.title"
        :value="metric.value"
      />
    </div>

    <!-- 服务器列表 -->
    <div class="server-list">
      <h3 class="section-title">服务器状态监控（共 {{ serverData.length }} 台）</h3>
      <ServerTable :data="serverData" />
    </div>
  </div>
</template>

<style scoped>
.overview-container {
  padding: 24px;
  background: #fff;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
  margin-bottom: 30px;
}

.server-list {
  border: 1px solid #ebeef5;
  border-radius: 6px;
  padding: 16px;
}

.section-title {
  color: #606266;
  margin: 0 0 16px 0;
  font-size: 16px;
}

@media (max-width: 768px) {
  .metrics-grid {
    grid-template-columns: 1fr;
  }
  
  .server-list {
    overflow-x: auto;
  }
}
</style>
